﻿<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>更新源数据</title>
    <link href="../../Scripts/jquery-easyui/themes/bootstrap/easyui.css" rel="stylesheet" />
    <script src="../../Scripts/jquery-easyui/jquery.min.js"></script>
    <script src="../../Scripts/jquery-easyui/jquery.easyui.min.js"></script>
    <script src="../../Scripts/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
    <link href="../../Content/themes/icon.css" rel="stylesheet" />
    <link href="../../Content/themes/table.css" rel="stylesheet" />
    <link href="../../Content/formstyles.css?v=1" rel="stylesheet" /> 
    <script src="../../Content/js/common.js"></script>

    
</head>
<body> 
    <div id="ui_main_layout" class="easyui-layout" data-options="fit:true,border:false">
        <div data-options="region:'center',border:false">
            <table id="ui_main_dg" data-options="fit:true,border:true"></table>
        </div>  
        <!--<a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-search" plain="true"
           onclick="refreshData();">刷新能源环保事业部2020年度领料数据</a>-->
</div>  
    <script type="text/javascript"> 
        function refreshData(id) {
            if (id == "1-2020") {
                $.getJSON('/Cache/reDepMonthtItemAmount', { deptName: '能源环保事业部', year: 2020 }, function (data) {
                    // "msg\":\"更新失败！\",\"success\":false}"
                    if (data.success) {
                        $.show_alert("消息", data.msg);
                        $("#ui_main_dg").datagrid("reload");
                    } else {
                        $.show_alert("失败", data.msg);
                    }

                });
            } else {

                $.show_alert("消息", id+"未配置数据更新方法！");
            }
        };
        var myColums = [[
                            { field: "id", width: "120", title: "数据代码", align: 'center',  },
                            { field: "updateTime", width: "180", title: "更新时间", align: 'center',  },
                            { field: "remark", width: "220", title: "数据描述", align: 'center' }, 
                           {
                               width: 100, title: '操作', field: '_operate',align: 'right' , formatter:
                                  function (val, row, index) {
                                      return '<a href="javascript:void(0)" onclick="refreshData(\'' + row.id + '\')">更新数据</a>';
                                  }
                           },
        ]];


        $(function () {


            $("#ui_main_dg").datagrid({       //初始化datagrid
                url: "/Cache/getCacheList?&r=" + Math.random(),
                striped: true, rownumbers: true, pagination: true, pageSize: 20, singleSelect: true, multiSort: false,
                //idField: 'id',
                //sortName: 'UpdateTime',
                //sortOrder: 'desc',
                pageList: [20, 40, 60, 80, 100],
                // frozenColumns:  ,
                columns: myColums,
                onDblClickRow: function (index, row) {
                    
                }, 
                
            });

        })

        //$(function () {
        //    $("#ui_main_dg").datagrid({       //初始化datagrid
        //        url: "/Cache/getCacheList?&r=" + Math.random(),
        //        striped: true, rownumbers: true, pagination: true, pageSize: 20, singleSelect: true,
        //        queryParams: {
        //            // "view": viewdata.view,
        //        },
        //        idField: 'id',
        //        columns: columns,
        //        sort: 'updateTime',
        //        order: 'desc',
        //        pageList: [20, 40, 60, 80, 100], 
        //        columns: columns,
        //        toolbar: toolbar.length == 0 ? null : toolbar,
        //        onSelect: function (rowIndex, rowData) { 
        //        },
        //        onLoadSuccess: function (data) { }
        //    });
        //});

        </Script>
   
</body>
    </html>
